<template>
  <div style="height: 100%; width: 100%">
    <!-- <div>累计同比增幅</div> -->
    <div id="negativeValue" style="height: 100%; width: 100%"></div>
  </div>
</template>

 <script>
export default {
  name: "negativeValue",
  props: {
    chartsData: {
      type: Object,
      default: () => {
        return {};
      },
    },
  },
  watch: {
    chartsData(val) {
      this.getPie(val);
    },
  },
  methods: {
    getPie(val) {
      var myChart = this.$echarts.init(document.getElementById("negativeValue"));
      var option = {
        title: {
            text: '累计同比增幅',
            left: '30%'
        },
        tooltip: {
            trigger: 'axis',
            axisPointer: {            // 坐标轴指示器，坐标轴触发有效
                type: 'shadow'        // 默认为直线，可选为：'line' | 'shadow'
            }
        },
        grid:{
            x: 150
        },
        xAxis: {
          splitLine: {
            show: false,
          },
          axisLabel: {
            show: false,
          },
          axisTick: {
            //y轴刻度线
            show: false,
          },
          axisLine: {
            //y轴
            show: false,
          },
        },
        yAxis: [
            {
                type: 'category',
                axisTick: {
                    show: false
                },
                data: val.areaName
            }
        ],
        series: [
          {
            type: "bar",
            data: val.tbInrease,
            label: {
                show: true,
                position: 'right'
            },
            emphasis: {
                focus: 'series'
            },
            itemStyle: {
              normal: {
                color: "#4F80BD",
                label: {
                  show: true,
                  position: "right",
                  textStyle: {
                    color: "black",
                  },
                  formatter:function(params){ //标签内容
                    return  params.value+'%'
                    },
                },
              },
            },
          },
        ],
      };
      myChart.setOption(option);
    },
  },
};
</script>

 <style>
</style>
